package com.cloud.form.api.translator;

import java.util.Iterator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aspose.words.Bookmark;
import com.aspose.words.BookmarkCollection;
import com.aspose.words.Document;
import com.cloud.form.api.entity.FormAssemblyInst;

public class CalendarTranslator{
	private static final Logger logger = LoggerFactory.getLogger(CalendarTranslator.class);

	public static void translator(Document doc, String bookmark, String value, FormAssemblyInst inst) {
		BookmarkCollection bookMarks = doc.getRange().getBookmarks();
		@SuppressWarnings("unchecked")
		Iterator<Bookmark> it = bookMarks.iterator();
		while (it.hasNext()) {
			Bookmark mark = it.next();
			if (mark.getName().equals(bookmark)) {
				try {
					mark.setText(value);
				} catch (Exception e) {
					logger.error("Calendar替换失败", e);
				}
			}
		}
	}

}
